/*Joseph A. Coll
Cleaning RCV AP Data
7/23/2025*/

cd "G:\My Drive\Backup 08202022\Working Papers\RCV and AP\Data and Methods"
*Import Qualtrics data, remove practice runs, save as .dta
	import delimited using "RCV AP Data.csv", clear
	save "RCV AP Data.dta", replace
	
	import delimited using "RCV AP Data Demos.csv", clear
	rename participantid prolific_pid

	*Age
	fre age
	destring age, ignore("CONSENT_REVOKED") replace
	fre age

	*Gender
	tab sex
	rename sex female_prolific_orig
	gen female_prolific = .
	replace female_prolific = 1 if female_prolific_orig == "Female"
	replace female_prolific = 0 if female_prolific_orig == "Male"
	replace female_prolific = . if female_prolific_orig == "CONSENT_REVOKED"
	label def female 1 "Female" 0 "Male", replace
	label val female_prolific female 
	fre female_prolific

	save "RCV AP Data Demos.dta", replace

*Load data
cd "G:\My Drive\Backup 08202022\Working Papers\RCV and AP\Data and Methods"
	use "RCV AP Data Uncleaned.dta", clear
	*Remove testing data
	bro startdate enddate prolific_pid exp_cond
	drop in 1/44
	drop if prolific_pid == ""
	sort prolific_pid startdate
	drop if exp_cond == .
	bysort prolific_pid: gen id = _n 
	sum id
	tab id

*Merge prolific demos	
merge 1:1 prolific_pid using "RCV AP Data Demos.dta", gen(_mergeS2DEMOS)
bro if _mergeS2DEMOS ==1
bro if _mergeS2DEMOS ==2
drop if _mergeS2DEMOS ==2

*Treatment
fre exp_cond
label def exp_cond 1 "Plurality: Lib-->Cons" 2 "RCV: Lib-->Cons" 3 "RCV Endorse: Lib-->Cons" ///
4 "Plurality: Cons-->Lib" 5 "RCV: Cons-->Lib" 6 "RCV Endorse: Cons-->Lib", replace
label val exp_cond exp_cond
fre exp_cond

gen treatment = .
replace treatment = 1 if exp_cond == 1 | exp_cond ==4 /*Plurality*/
replace treatment = 2 if exp_cond == 2 | exp_cond ==5 /*RCV*/
replace treatment = 3 if exp_cond == 3 | exp_cond ==6 /*RCV Endorse*/
label def treatment 1 "Plurality Compliment" 2 "RCV Compliment" 3 "RCV Comp. + Endorse", replace
label val treatment treatment
fre treatment

*Ideology
fre ideoss1
gen conservativism = .
replace conservativism = 1 if ideoss1 == "Very liberal"
replace conservativism = 2 if ideoss1 == "Liberal"
replace conservativism = 3 if ideoss1 == "Somewhat liberal"
replace conservativism = 4 if ideoss1 == "True Moderate"
replace conservativism = 5 if ideoss1 == "Somewhat conservative"
replace conservativism = 6 if ideoss1 == "Conservative"
replace conservativism = 7 if ideoss1 == "Very conservative"
label def conservativism 1 "Very liberal" 2 "Liberal" 3 "Somewhat liberal" 4 "Moderate" 5 "Somewhat conservative" 6 "Conservative" 7 "Very Conservative", replace
label val conservativism conservativism
label var conservativism Conservativism
fre conservativism

fre ideos2
replace conservativism = 3 if ideos2 == "Closer to the liberal political viewpoint"
replace conservativism = 5 if ideos2 == "Closer to the conservative political viewpoint"
fre conservativism

tab conservativism
gen liberal = .
replace liberal = 1 if ideoss1 == "Liberal" | ideoss1 == "Somewhat liberal" | ideoss1 == "Very liberal" | ideos2 == "Closer to the liberal political viewpoint"
replace liberal = 0 if liberal != 1
label var liberal Liberal
tab liberal

gen conserv = .
replace conserv = 1 if ideoss1 == "Conservative" | ideoss1 == "Somewhat conservative" | ideoss1 == "Very conservative" | ideos2 == "Closer to the conservative political viewpoint"
replace conserv = 0 if conserv != 1
label var conserv Conservative
tab conserv

gen moderate = .
replace moderate = 1 if ideoss1 == "Moderate" | ideoss1 == "Other" | ideoss1 == "Haven't thought much about it" 
replace moderate = 0 if moderate != 1
label var moderate Moderate
tab moderate

*Traits
label def traits_pos 5 "Extremely well" 4 "Very well" 3 "Somewhat well" 2 "Not too well" 1 "Not at all well", replace

*Conservative
	*Patriotic (Conservative)
	fre traits_c_1
	gen pre_t_pat_cons = .
	replace pre_t_pat_cons = 4 if traits_c_1 == "Extremely well"
	replace pre_t_pat_cons = 3 if traits_c_1 == "Very well"
	replace pre_t_pat_cons = 2 if traits_c_1 == "Somewhat well"
	replace pre_t_pat_cons = 1 if traits_c_1 == "Not too well"
	replace pre_t_pat_cons = 0 if traits_c_1 == "Not at all well"
	label var pre_t_pat_cons "Traits: Patriotic (Conservative)"
	label val pre_t_pat_cons traits_pos
	fre pre_t_pat_cons 

	*Intelligent (Conservative)
	fre traits_c_2
	gen pre_t_int_cons = .
	replace pre_t_int_cons = 4 if traits_c_2 == "Extremely well"
	replace pre_t_int_cons = 3 if traits_c_2 == "Very well"
	replace pre_t_int_cons = 2 if traits_c_2 == "Somewhat well"
	replace pre_t_int_cons = 1 if traits_c_2 == "Not too well"
	replace pre_t_int_cons = 0 if traits_c_2 == "Not at all well"
	label var pre_t_int_cons "Traits: Intelligent (Conservative)"
	label val pre_t_int_cons traits_pos
	fre pre_t_int_cons 

	*Honest (Conservative)
	fre traits_c_3
	gen pre_t_hon_cons = .
	replace pre_t_hon_cons = 4 if traits_c_3 == "Extremely well"
	replace pre_t_hon_cons = 3 if traits_c_3 == "Very well"
	replace pre_t_hon_cons = 2 if traits_c_3 == "Somewhat well"
	replace pre_t_hon_cons = 1 if traits_c_3 == "Not too well"
	replace pre_t_hon_cons = 0 if traits_c_3 == "Not at all well"
	label var pre_t_hon_cons "Traits: Honest (Conservative)"
	label val pre_t_hon_cons traits_pos
	fre pre_t_hon_cons 

	*Open-Minded (Conservative)
	fre traits_c_4
	gen pre_t_opm_cons = .
	replace pre_t_opm_cons = 4 if traits_c_4 == "Extremely well"
	replace pre_t_opm_cons = 3 if traits_c_4 == "Very well"
	replace pre_t_opm_cons = 5 if traits_c_4 == "Somewhat well"
	replace pre_t_opm_cons = 1 if traits_c_4 == "Not too well"
	replace pre_t_opm_cons = 0 if traits_c_4 == "Not at all well"
	label var pre_t_opm_cons "Traits: Open-Minded (Conservative)"
	label val pre_t_opm_cons traits_pos
	fre pre_t_opm_cons 

	*Generous (Conservative)
	fre traits_c_5
	gen pre_t_gen_cons = .
	replace pre_t_gen_cons = 4 if traits_c_5 == "Extremely well"
	replace pre_t_gen_cons = 3 if traits_c_5 == "Very well"
	replace pre_t_gen_cons = 5 if traits_c_5 == "Somewhat well"
	replace pre_t_gen_cons = 1 if traits_c_5 == "Not too well"
	replace pre_t_gen_cons = 0 if traits_c_5 == "Not at all well"
	label var pre_t_gen_cons "Traits: Generous (Conservative)"
	label val pre_t_gen_cons traits_pos
	fre pre_t_gen_cons 

	*Hypocritical (Conservative)
	fre traits_c_6
	gen pre_t_hyp_cons = .
	replace pre_t_hyp_cons = 1 if traits_c_6 == "Extremely well"
	replace pre_t_hyp_cons = 2 if traits_c_6 == "Very well"
	replace pre_t_hyp_cons = 3 if traits_c_6 == "Somewhat well"
	replace pre_t_hyp_cons = 4 if traits_c_6 == "Not too well"
	replace pre_t_hyp_cons = 5 if traits_c_6 == "Not at all well"
	label var pre_t_hyp_cons "Traits: Hypocritical (Conservative)"
	label val pre_t_hyp_cons traits_pos
	fre pre_t_hyp_cons 

	*Selfish (Conservative)
	fre traits_c_7
	gen pre_t_slf_cons = .
	replace pre_t_slf_cons = 1 if traits_c_7 == "Extremely well"
	replace pre_t_slf_cons = 2 if traits_c_7 == "Very well"
	replace pre_t_slf_cons = 3 if traits_c_7 == "Somewhat well"
	replace pre_t_slf_cons = 4 if traits_c_7 == "Not too well"
	replace pre_t_slf_cons = 5 if traits_c_7 == "Not at all well"
	label var pre_t_slf_cons "Traits: Selfish (Conservative)"
	label val pre_t_slf_cons traits_pos
	fre pre_t_slf_cons 

	*Mean (Conservative)
	fre traits_c_8
	gen pre_t_men_cons = .
	replace pre_t_men_cons = 1 if traits_c_8 == "Extremely well"
	replace pre_t_men_cons = 2 if traits_c_8 == "Very well"
	replace pre_t_men_cons = 3 if traits_c_8 == "Somewhat well"
	replace pre_t_men_cons = 4 if traits_c_8 == "Not too well"
	replace pre_t_men_cons = 5 if traits_c_8 == "Not at all well"
	label var pre_t_men_cons "Traits: Mean (Conservative)"
	label val pre_t_men_cons traits_pos
	fre pre_t_men_cons 

*Liberal
	*Patriotic (Liberal)
	fre traits_l_1
	gen pre_t_pat_lib = .
	replace pre_t_pat_lib = 4 if traits_l_1 == "Extremely well"
	replace pre_t_pat_lib = 3 if traits_l_1 == "Very well"
	replace pre_t_pat_lib = 2 if traits_l_1 == "Somewhat well"
	replace pre_t_pat_lib = 1 if traits_l_1 == "Not too well"
	replace pre_t_pat_lib = 0 if traits_l_1 == "Not at all well"
	label var pre_t_pat_lib "Traits: Patriotic (Liberal)"
	label val pre_t_pat_lib traits_pos
	fre pre_t_pat_lib 

	*Intelligent (Liberal)
	fre traits_l_2
	gen pre_t_int_lib = .
	replace pre_t_int_lib = 4 if traits_l_2 == "Extremely well"
	replace pre_t_int_lib = 3 if traits_l_2 == "Very well"
	replace pre_t_int_lib = 5 if traits_l_2 == "Somewhat well"
	replace pre_t_int_lib = 1 if traits_l_2 == "Not too well"
	replace pre_t_int_lib = 0 if traits_l_2 == "Not at all well"
	label var pre_t_int_lib "Traits: Intelligent (Liberal)"
	label val pre_t_int_lib traits_pos
	fre pre_t_int_lib 

	*Honest (Liberal)
	fre traits_l_3
	gen pre_t_hon_lib = .
	replace pre_t_hon_lib = 4 if traits_l_3 == "Extremely well"
	replace pre_t_hon_lib = 3 if traits_l_3 == "Very well"
	replace pre_t_hon_lib = 2 if traits_l_3 == "Somewhat well"
	replace pre_t_hon_lib = 1 if traits_l_3 == "Not too well"
	replace pre_t_hon_lib = 0 if traits_l_3 == "Not at all well"
	label var pre_t_hon_lib "Traits: Honest (Liberal)"
	label val pre_t_hon_lib traits_pos
	fre pre_t_hon_lib 

	*Open-Minded (Liberal)
	fre traits_l_4
	gen pre_t_opm_lib = .
	replace pre_t_opm_lib = 4 if traits_l_4 == "Extremely well"
	replace pre_t_opm_lib = 3 if traits_l_4 == "Very well"
	replace pre_t_opm_lib = 2 if traits_l_4 == "Somewhat well"
	replace pre_t_opm_lib = 1 if traits_l_4 == "Not too well"
	replace pre_t_opm_lib = 0 if traits_l_4 == "Not at all well"
	label var pre_t_opm_lib "Traits: Open-Minded (Liberal)"
	label val pre_t_opm_lib traits_pos
	fre pre_t_opm_lib 

	*Generous (Liberal)
	fre traits_l_5
	gen pre_t_gen_lib = .
	replace pre_t_gen_lib = 4 if traits_l_5 == "Extremely well"
	replace pre_t_gen_lib = 3 if traits_l_5 == "Very well"
	replace pre_t_gen_lib = 2 if traits_l_5 == "Somewhat well"
	replace pre_t_gen_lib = 1 if traits_l_5 == "Not too well"
	replace pre_t_gen_lib = 0 if traits_l_5 == "Not at all well"
	label var pre_t_gen_lib "Traits: Generous (Liberal)"
	label val pre_t_gen_lib traits_pos
	fre pre_t_gen_lib 

	*Hypocritical (Liberal)
	fre traits_l_6
	gen pre_t_hyp_lib = .
	replace pre_t_hyp_lib = 0 if traits_l_6 == "Extremely well"
	replace pre_t_hyp_lib = 1 if traits_l_6 == "Very well"
	replace pre_t_hyp_lib = 2 if traits_l_6 == "Somewhat well"
	replace pre_t_hyp_lib = 3 if traits_l_6 == "Not too well"
	replace pre_t_hyp_lib = 4 if traits_l_6 == "Not at all well"
	label var pre_t_hyp_lib "Traits: Hypocritical (Liberal)"
	label val pre_t_hyp_lib traits_pos
	fre pre_t_hyp_lib 

	*Selfish (Liberal)
	fre traits_l_7
	gen pre_t_slf_lib = .
	replace pre_t_slf_lib = 0 if traits_l_7 == "Extremely well"
	replace pre_t_slf_lib = 1 if traits_l_7 == "Very well"
	replace pre_t_slf_lib = 2 if traits_l_7 == "Somewhat well"
	replace pre_t_slf_lib = 3 if traits_l_7 == "Not too well"
	replace pre_t_slf_lib = 4 if traits_l_7 == "Not at all well"
	label var pre_t_slf_lib "Traits: Selfish (Liberal)"
	label val pre_t_slf_lib traits_pos
	fre pre_t_slf_lib 

	*Mean (Liberal)
	fre traits_l_8
	gen pre_t_men_lib = .
	replace pre_t_men_lib = 0 if traits_l_8 == "Extremely well"
	replace pre_t_men_lib = 1 if traits_l_8 == "Very well"
	replace pre_t_men_lib = 2 if traits_l_8 == "Somewhat well"
	replace pre_t_men_lib = 3 if traits_l_8 == "Not too well"
	replace pre_t_men_lib = 4 if traits_l_8 == "Not at all well"
	label var pre_t_men_lib "Traits: Mean (Liberal)"
	label val pre_t_men_lib traits_pos
	fre pre_t_men_lib 

sum pre_t_pat_cons pre_t_int_cons pre_t_hon_cons pre_t_opm_cons pre_t_gen_cons pre_t_hyp_cons pre_t_slf_cons pre_t_men_cons pre_t_pat_lib pre_t_int_lib pre_t_hon_lib pre_t_opm_lib pre_t_gen_lib pre_t_hyp_lib pre_t_slf_lib pre_t_men_lib
local vars pre_t_pat_cons pre_t_int_cons pre_t_hon_cons pre_t_opm_cons pre_t_gen_cons pre_t_hyp_cons pre_t_slf_cons pre_t_men_cons pre_t_pat_lib pre_t_int_lib pre_t_hon_lib pre_t_opm_lib pre_t_gen_lib pre_t_hyp_lib pre_t_slf_lib pre_t_men_lib
foreach x of local vars {
clonevar `x'_bin = `x'
replace `x'_bin = (`x'_bin)/4
}
sum pre_t_pat_cons_bin pre_t_int_cons_bin pre_t_hon_cons_bin pre_t_opm_cons_bin pre_t_gen_cons_bin pre_t_hyp_cons_bin pre_t_slf_cons_bin pre_t_men_cons_bin pre_t_pat_lib_bin pre_t_int_lib_bin pre_t_hon_lib_bin pre_t_opm_lib_bin pre_t_gen_lib_bin pre_t_hyp_lib_bin pre_t_slf_lib_bin pre_t_men_lib_bin

*Pre-FT
	*Conservative
	fre ft_1
	gen pre_ft_cons = ft_1
	replace  pre_ft_cons = pre_ft_cons /100
	label var pre_ft_cons "FT: Conservatives"
	fre pre_ft_cons 
	
	*Liberal
	fre ft_2
	gen pre_ft_lib = ft_2
	replace  pre_ft_lib = pre_ft_lib /100
	label var pre_ft_lib "FT: Liberals"
	fre pre_ft_lib 

*Age
tab yearborn_1
replace yearborn_1 = . if yearborn_1 <1943 | yearborn_1 >2006
rename age age_original
gen age = 2025-yearborn_1
tab age

replace age = age_original if age == .
replace age = 43 if age == .
label var age Age
sum age
fre age

*Gender
fre gender
gen female = 1 if gender == "Female"
replace female = 0 if gender != "Female"
label def female 1 "Female" 0 "Other", replace
label val female female
label var female Female
fre female

*Race
fre ethnicitysimplified
gen white = .
replace white =1 if ethnicitysimplified == "White"
replace white =0 if ethnicitysimplified != "White"
label var white White
fre white

*Educ
fre education
fre education, nol
gen bach_above = .
replace bach_above = 1 if education == "4-year college degree (e.g., Bachelor's degree)"
replace bach_above = 1 if education == "Post-graduate degree (e.g., Masters, Doctorate)"
replace bach_above = 0 if education != "4-year college degree (e.g., Bachelor's degree)"
label var bach_above "Bach./Adv. Degree"
fre bach_above

gen educ = .
replace educ = 1 if education == "Did not graduate from high school" | education == "High school graduate or equivalent"
replace educ = 2 if education == "Some college, but no degree (e.g., still attending college or dropped out before finishing)"
replace educ = 3 if education == "2-year college degree (e.g., Associate's degree)"
replace educ = 4 if education == "4-year college degree (e.g., Bachelor's degree)"
replace educ = 5 if education == "Post-graduate degree (e.g., Masters, Doctorate)"
label var educ Education
fre educ 

*Partisanship
fre pid
fre pid_rep
fre pid_dem
fre pid_ind

gen dem_wlean = .
replace dem_wlean = 1 if pid == "Democrat" | pid_ind == "Closer to the Democratic party"
replace dem_wlean = 0 if dem_wlean  != 1
label var dem_wlean "Demcorat"
fre dem_wlean

gen rep_wlean = .
replace rep_wlean = 1 if pid == "Republican" | pid_ind == "Closer to the Republican party"
replace rep_wlean = 0 if rep_wlean  != 1
label var rep_wlean "Republican"
fre rep_wlean

gen ind_nolean = .
replace ind_nolean = 1 if pid_ind == "Neither"
replace ind_nolean = 0 if ind_nolean  != 1
label var ind_nolean "Independent"
fre ind_nolean

gen pid_scale3 = . 
replace pid_scale3 = 1 if dem_wlean ==1 
replace pid_scale3 = 2 if ind_nolean ==1 
replace pid_scale3 = 3 if rep_wlean ==1 
fre pid_scale3

*Political interest
fre poli_int
rename poli_int poli_int_orig
gen poli_int = .
replace poli_int = 1 if poli_int_orig == "Hardly at all"
replace poli_int = 2 if poli_int_orig == "Only now and then"
replace poli_int = 3 if poli_int_orig == "Some of the time"
replace poli_int = 4 if poli_int_orig == "Most of the time"
label def poli_int 1 "Never" 2 "Rarely" 3 "Sometimes" 4 "Often", replace 
label val poli_int poli_int 
label var poli_int "Political Interest"
fre poli_int 

gen poli_int_01 = .
replace poli_int_01 = (poli_int-1)/3
label var poli_int_01 "Political Interest"
fre poli_int_01 

*News Trust
fre trust_news
rename trust_news trust_news_orig
gen news_trust = .
replace news_trust = 1 if trust_news_orig == "Never"
replace news_trust = 2 if trust_news_orig == "Rarely"
replace news_trust = 3 if trust_news_orig == "Sometimes"
replace news_trust = 4 if trust_news_orig == "Often"
replace news_trust = 5 if trust_news_orig == "Always"
label def news_trust 1 "Never" 2 "Rarely" 3 "Sometimes" 4 "Often" 5 "Always", replace 
label val news_trust news_trust 
label var news_trust "News Trust"
fre news_trust 

gen news_trust_01 = .
replace news_trust_01 = (news_trust-1)/4
label var news_trust_01 "News Trust"
fre news_trust_01 

*MVC
label def mvc_correct 1 "Correct" 0 "Incorrect", replace
	
	*Topic
	fre mvc_topic 
	gen mvc_topic_correct = .
	replace mvc_topic_correct = 1 if mvc_topic == "Event Licensing in stadiums"
	replace mvc_topic_correct = 0 if mvc_topic != "Event Licensing in stadiums"
	label val mvc_topic_correct mvc_correct
	label var mvc_topic_correct "MVC: Topic"
	fre mvc_topic_correct
	
	*Goal
	fre mvc_goal 
	gen mvc_goal_correct = .
	replace mvc_goal_correct = 1 if mvc_goal == "A single license will cover all events occurring in a stadium"
	replace mvc_goal_correct = 0 if mvc_goal != "A single license will cover all events occurring in a stadium"
	label val mvc_goal_correct mvc_correct
	label var mvc_goal_correct "MVC: Goal"
	fre mvc_goal_correct

	*Effect
	fre mvc_effect 
	gen mvc_effect_correct = .
	replace mvc_effect_correct = 1 if mvc_effect == "There may be a special hearing held by lawmakers"
	replace mvc_effect_correct = 0 if mvc_effect != "There may be a special hearing held by lawmakers"
	label val mvc_effect_correct mvc_correct
	label var mvc_effect_correct "MVC: Effect"
	fre mvc_effect_correct

	*Total
	gen mvc_correct_total = .
	replace mvc_correct_total = mvc_topic_correct+ mvc_goal_correct + mvc_effect_correct
	label var mvc_correct_total "MVC Score"
	fre mvc_correct_total
	
*Next buttons
local vars mvc_next plc_next rlc_next relc_next pcl_next rcl_next recl_next
foreach x of local vars {
	fre `x'
	gen `x'_clicked = .
	replace `x'_clicked = 1 if `x' == "Next"
	replace `x'_clicked = 0 if `x' != "Next"
	}
 
fre exp_cond
replace plc_next_clicked = . if exp_cond  != 1
replace rlc_next_clicked = . if exp_cond  != 2
replace relc_next_clicked = . if exp_cond  != 3
replace pcl_next_clicked = . if exp_cond  != 4
replace rcl_next_clicked = . if exp_cond  != 5
replace recl_next_clicked = . if exp_cond  != 6

local vars plc_next_clicked rlc_next_clicked relc_next_clicked pcl_next_clicked rcl_next_clicked recl_next_clicked
foreach x of local vars {
	fre `x'
	}
 
*FMC
label def fmc_correct 1 "Correct" 0 "Incorrect", replace
fre exp_cond

	*Ideology
	fre fmc_ideo
	gen fmc_ideo_correct = .
	replace fmc_ideo_correct = 1 if fmc_ideo == "Conservative" & exp_cond >3
	replace fmc_ideo_correct = 1 if fmc_ideo == "Liberal" & exp_cond <4
	
	replace fmc_ideo_correct = 0 if fmc_ideo == "Conservative" & exp_cond <4
	replace fmc_ideo_correct = 0 if fmc_ideo == "Liberal" & exp_cond >3
	replace fmc_ideo_correct = 0 if fmc_ideo == "Independent"
	replace fmc_ideo_correct = 0 if fmc_ideo == "Moderate"
 	replace fmc_ideo_correct = 0 if fmc_ideo == "Communist"
	replace fmc_ideo_correct = 0 if fmc_ideo == ""
   
	label val fmc_ideo_correct fmc_correct
	label var fmc_ideo_correct "FMC: Candidate Ideology"
	fre fmc_ideo_correct
	
	*Election Type
	fre fmc_elect
	gen fmc_elect_correct = .
	replace fmc_elect_correct = 1 if fmc_elect == "Plurality election" & exp_cond ==1
	replace fmc_elect_correct = 1 if fmc_elect == "Plurality election" & exp_cond ==4
	
	replace fmc_elect_correct = 1 if fmc_elect == "Ranked choice voting election" & exp_cond ==2
	replace fmc_elect_correct = 1 if fmc_elect == "Ranked choice voting election" & exp_cond ==3
	replace fmc_elect_correct = 1 if fmc_elect == "Ranked choice voting election" & exp_cond ==5
	replace fmc_elect_correct = 1 if fmc_elect == "Ranked choice voting election" & exp_cond ==6	
	
	replace fmc_elect_correct = 0 if fmc_elect == "Plurality election" & exp_cond ==2
	replace fmc_elect_correct = 0 if fmc_elect == "Plurality election" & exp_cond ==3
	replace fmc_elect_correct = 0 if fmc_elect == "Plurality election" & exp_cond ==5
	replace fmc_elect_correct = 0 if fmc_elect == "Plurality election" & exp_cond ==6	
	
	replace fmc_elect_correct = 0 if fmc_elect == "Ranked choice voting election" & exp_cond ==1
	replace fmc_elect_correct = 0 if fmc_elect == "Ranked choice voting election" & exp_cond ==4
	
	replace fmc_elect_correct = 0 if fmc_elect == "Proportional representation election"
	replace fmc_elect_correct = 0 if fmc_elect == "Mixed-member district election"
	replace fmc_elect_correct = 0 if fmc_elect == "At-large election"
	replace fmc_elect_correct = 0 if fmc_elect == ""
	
	label val fmc_elect_correct fmc_correct
	label var fmc_elect_correct "FMC: Election Type"
	fre fmc_elect_correct
	
	*Story
	fre fmc_story
	gen fmc_story_correct = .
	replace fmc_story_correct = 1 if fmc_story == "Complimented the other candidate" & exp_cond == 1 
	replace fmc_story_correct = 1 if fmc_story == "Complimented the other candidate" & exp_cond == 2 
	replace fmc_story_correct = 1 if fmc_story == "Complimented the other candidate" & exp_cond == 4 
	replace fmc_story_correct = 1 if fmc_story == "Complimented the other candidate" & exp_cond == 5 

	replace fmc_story_correct = 1 if fmc_story == "Endorsed the other candidate" & exp_cond == 3 
	replace fmc_story_correct = 1 if fmc_story == "Endorsed the other candidate" & exp_cond == 6 

	replace fmc_story_correct = 0 if fmc_story == "Endorsed the other candidate" & exp_cond == 1 
	replace fmc_story_correct = 0 if fmc_story == "Endorsed the other candidate" & exp_cond == 2 
	replace fmc_story_correct = 0 if fmc_story == "Endorsed the other candidate" & exp_cond == 4 
	replace fmc_story_correct = 0 if fmc_story == "Endorsed the other candidate" & exp_cond == 5 

	replace fmc_story_correct = 0 if fmc_story == "Complimented the other candidate" & exp_cond == 3 
	replace fmc_story_correct = 0 if fmc_story == "Complimented the other candidate" & exp_cond == 6 

	replace fmc_story_correct = 0 if fmc_story == "Insulted the other candidate"  
	replace fmc_story_correct = 0 if fmc_story == "Assaulted the other candidate"  
	replace fmc_story_correct = 0 if fmc_story == "Accused the other candidate of violating campaign finance laws"  
	replace fmc_story_correct = 0 if fmc_story == ""
	
	label val fmc_story_correct fmc_correct
	label var fmc_story_correct "FMC: Candidate Interaction"
	fre fmc_story_correct

	*Total
	gen fmc_correct_total = .
	replace fmc_correct_total = fmc_ideo_correct + fmc_elect_correct + fmc_story_correct
	label var fmc_correct_total "FMC Score"
	fre fmc_correct_total
	
*Post-FT
	*Conservative
	fre post_ap_ft_2
	gen post_ft_cons = post_ap_ft_2
	replace  post_ft_cons = post_ft_cons /100
	label var post_ft_cons "FT: Conservatives"
	fre post_ft_cons 
	
	*Liberal
	fre post_ap_ft_1
	gen post_ft_lib = post_ap_ft_1
	replace  post_ft_lib = post_ft_lib /100
	label var post_ft_lib "FT: Liberals"
	fre post_ft_lib 

*Traits
*Conservative
	*Patriotic (Conservative)
	fre post_ap_trait_r_1
	gen post_t_pat_cons = .
	replace post_t_pat_cons = 4 if post_ap_trait_r_1 == "Extremely well"
	replace post_t_pat_cons = 3 if post_ap_trait_r_1 == "Very well"
	replace post_t_pat_cons = 2 if post_ap_trait_r_1 == "Somewhat well"
	replace post_t_pat_cons = 1 if post_ap_trait_r_1 == "Not too well"
	replace post_t_pat_cons = 0 if post_ap_trait_r_1 == "Not at all well"
	label var post_t_pat_cons "Traits: Patriotic (Conservative)"
	label val post_t_pat_cons traits_pos
	fre post_t_pat_cons 

	*Intelligent (Conservative)
	fre post_ap_trait_r_2
	gen post_t_int_cons = .
	replace post_t_int_cons = 4 if post_ap_trait_r_2 == "Extremely well"
	replace post_t_int_cons = 3 if post_ap_trait_r_2 == "Very well"
	replace post_t_int_cons = 2 if post_ap_trait_r_2 == "Somewhat well"
	replace post_t_int_cons = 1 if post_ap_trait_r_2 == "Not too well"
	replace post_t_int_cons = 0 if post_ap_trait_r_2 == "Not at all well"
	label var post_t_int_cons "Traits: Intelligent (Conservative)"
	label val post_t_int_cons traits_pos
	fre post_t_int_cons 

	*Honest (Conservative)
	fre post_ap_trait_r_3
	gen post_t_hon_cons = .
	replace post_t_hon_cons = 4 if post_ap_trait_r_3 == "Extremely well"
	replace post_t_hon_cons = 3 if post_ap_trait_r_3 == "Very well"
	replace post_t_hon_cons = 2 if post_ap_trait_r_3 == "Somewhat well"
	replace post_t_hon_cons = 1 if post_ap_trait_r_3 == "Not too well"
	replace post_t_hon_cons = 0 if post_ap_trait_r_3 == "Not at all well"
	label var post_t_hon_cons "Traits: Honest (Conservative)"
	label val post_t_hon_cons traits_pos
	fre post_t_hon_cons 

	*Open-Minded (Conservative)
	fre post_ap_trait_r_4
	gen post_t_opm_cons = .
	replace post_t_opm_cons = 4 if post_ap_trait_r_4 == "Extremely well"
	replace post_t_opm_cons = 3 if post_ap_trait_r_4 == "Very well"
	replace post_t_opm_cons = 2 if post_ap_trait_r_4 == "Somewhat well"
	replace post_t_opm_cons = 1 if post_ap_trait_r_4 == "Not too well"
	replace post_t_opm_cons = 0 if post_ap_trait_r_4 == "Not at all well"
	label var post_t_opm_cons "Traits: Open-Minded (Conservative)"
	label val post_t_opm_cons traits_pos
	fre post_t_opm_cons 

	*Generous (Conservative)
	fre post_ap_trait_r_5
	gen post_t_gen_cons = .
	replace post_t_gen_cons = 4 if post_ap_trait_r_5 == "Extremely well"
	replace post_t_gen_cons = 3 if post_ap_trait_r_5 == "Very well"
	replace post_t_gen_cons = 2 if post_ap_trait_r_5 == "Somewhat well"
	replace post_t_gen_cons = 1 if post_ap_trait_r_5 == "Not too well"
	replace post_t_gen_cons = 0 if post_ap_trait_r_5 == "Not at all well"
	label var post_t_gen_cons "Traits: Generous (Conservative)"
	label val post_t_gen_cons traits_pos
	fre post_t_gen_cons 

	*Hypocritical (Conservative)
	fre post_ap_trait_r_6
	gen post_t_hyp_cons = .
	replace post_t_hyp_cons = 0 if post_ap_trait_r_6 == "Extremely well"
	replace post_t_hyp_cons = 1 if post_ap_trait_r_6 == "Very well"
	replace post_t_hyp_cons = 2 if post_ap_trait_r_6 == "Somewhat well"
	replace post_t_hyp_cons = 3 if post_ap_trait_r_6 == "Not too well"
	replace post_t_hyp_cons = 4 if post_ap_trait_r_6 == "Not at all well"
	label var post_t_hyp_cons "Traits: Hypocritical (Conservative)"
	label val post_t_hyp_cons traits_pos
	fre post_t_hyp_cons 

	*Selfish (Conservative)
	fre post_ap_trait_r_7
	gen post_t_slf_cons = .
	replace post_t_slf_cons = 0 if post_ap_trait_r_7 == "Extremely well"
	replace post_t_slf_cons = 1 if post_ap_trait_r_7 == "Very well"
	replace post_t_slf_cons = 2 if post_ap_trait_r_7 == "Somewhat well"
	replace post_t_slf_cons = 3 if post_ap_trait_r_7 == "Not too well"
	replace post_t_slf_cons = 4 if post_ap_trait_r_7 == "Not at all well"
	label var post_t_slf_cons "Traits: Selfish (Conservative)"
	label val post_t_slf_cons traits_pos
	fre post_t_slf_cons 

	*Mean (Conservative)
	fre post_ap_trait_r_8
	gen post_t_men_cons = .
	replace post_t_men_cons = 0 if post_ap_trait_r_8 == "Extremely well"
	replace post_t_men_cons = 1 if post_ap_trait_r_8 == "Very well"
	replace post_t_men_cons = 2 if post_ap_trait_r_8 == "Somewhat well"
	replace post_t_men_cons = 3 if post_ap_trait_r_8 == "Not too well"
	replace post_t_men_cons = 4 if post_ap_trait_r_8 == "Not at all well"
	label var post_t_men_cons "Traits: Mean (Conservative)"
	label val post_t_men_cons traits_pos
	fre post_t_men_cons 

*Liberal
	*Patriotic (Liberal)
	fre post_ap_trait_l_1
	gen post_t_pat_lib = .
	replace post_t_pat_lib = 4 if post_ap_trait_l_1 == "Extremely well"
	replace post_t_pat_lib = 3 if post_ap_trait_l_1 == "Very well"
	replace post_t_pat_lib = 2 if post_ap_trait_l_1 == "Somewhat well"
	replace post_t_pat_lib = 1 if post_ap_trait_l_1 == "Not too well"
	replace post_t_pat_lib = 0 if post_ap_trait_l_1 == "Not at all well"
	label var post_t_pat_lib "Traits: Patriotic (Liberal)"
	label val post_t_pat_lib traits_pos
	fre post_t_pat_lib 

	*Intelligent (Liberal)
	fre post_ap_trait_l_2
	gen post_t_int_lib = .
	replace post_t_int_lib = 4 if post_ap_trait_l_2 == "Extremely well"
	replace post_t_int_lib = 3 if post_ap_trait_l_2 == "Very well"
	replace post_t_int_lib = 2 if post_ap_trait_l_2 == "Somewhat well"
	replace post_t_int_lib = 1 if post_ap_trait_l_2 == "Not too well"
	replace post_t_int_lib = 0 if post_ap_trait_l_2 == "Not at all well"
	label var post_t_int_lib "Traits: Intelligent (Liberal)"
	label val post_t_int_lib traits_pos
	fre post_t_int_lib 

	*Honest (Liberal)
	fre post_ap_trait_l_3
	gen post_t_hon_lib = .
	replace post_t_hon_lib = 4 if post_ap_trait_l_3 == "Extremely well"
	replace post_t_hon_lib = 3 if post_ap_trait_l_3 == "Very well"
	replace post_t_hon_lib = 2 if post_ap_trait_l_3 == "Somewhat well"
	replace post_t_hon_lib = 1 if post_ap_trait_l_3 == "Not too well"
	replace post_t_hon_lib = 0 if post_ap_trait_l_3 == "Not at all well"
	label var post_t_hon_lib "Traits: Honest (Liberal)"
	label val post_t_hon_lib traits_pos
	fre post_t_hon_lib 

	*Open-Minded (Liberal)
	fre post_ap_trait_l_4
	gen post_t_opm_lib = .
	replace post_t_opm_lib = 4 if post_ap_trait_l_4 == "Extremely well"
	replace post_t_opm_lib = 3 if post_ap_trait_l_4 == "Very well"
	replace post_t_opm_lib = 2 if post_ap_trait_l_4 == "Somewhat well"
	replace post_t_opm_lib = 1 if post_ap_trait_l_4 == "Not too well"
	replace post_t_opm_lib = 0 if post_ap_trait_l_4 == "Not at all well"
	label var post_t_opm_lib "Traits: Open-Minded (Liberal)"
	label val post_t_opm_lib traits_pos
	fre post_t_opm_lib 

	*Generous (Liberal)
	fre post_ap_trait_l_5
	gen post_t_gen_lib = .
	replace post_t_gen_lib = 4 if post_ap_trait_l_5 == "Extremely well"
	replace post_t_gen_lib = 3 if post_ap_trait_l_5 == "Very well"
	replace post_t_gen_lib = 2 if post_ap_trait_l_5 == "Somewhat well"
	replace post_t_gen_lib = 1 if post_ap_trait_l_5 == "Not too well"
	replace post_t_gen_lib = 0 if post_ap_trait_l_5 == "Not at all well"
	label var post_t_gen_lib "Traits: Generous (Liberal)"
	label val post_t_gen_lib traits_pos
	fre post_t_gen_lib 

	*Hypocritical (Liberal)
	fre post_ap_trait_l_6
	gen post_t_hyp_lib = .
	replace post_t_hyp_lib = 0 if post_ap_trait_l_6 == "Extremely well"
	replace post_t_hyp_lib = 1 if post_ap_trait_l_6 == "Very well"
	replace post_t_hyp_lib = 2 if post_ap_trait_l_6 == "Somewhat well"
	replace post_t_hyp_lib = 3 if post_ap_trait_l_6 == "Not too well"
	replace post_t_hyp_lib = 4 if post_ap_trait_l_6 == "Not at all well"
	label var post_t_hyp_lib "Traits: Hypocritical (Liberal)"
	label val post_t_hyp_lib traits_pos
	fre post_t_hyp_lib 

	*Selfish (Liberal)
	fre post_ap_trait_l_7
	gen post_t_slf_lib = .
	replace post_t_slf_lib = 0 if post_ap_trait_l_7 == "Extremely well"
	replace post_t_slf_lib = 1 if post_ap_trait_l_7 == "Very well"
	replace post_t_slf_lib = 2 if post_ap_trait_l_7 == "Somewhat well"
	replace post_t_slf_lib = 3 if post_ap_trait_l_7 == "Not too well"
	replace post_t_slf_lib = 4 if post_ap_trait_l_7 == "Not at all well"
	label var post_t_slf_lib "Traits: Selfish (Liberal)"
	label val post_t_slf_lib traits_pos
	fre post_t_slf_lib 

	*Mean (Liberal)
	fre post_ap_trait_l_8
	gen post_t_men_lib = .
	replace post_t_men_lib = 0 if post_ap_trait_l_8 == "Extremely well"
	replace post_t_men_lib = 1 if post_ap_trait_l_8 == "Very well"
	replace post_t_men_lib = 2 if post_ap_trait_l_8 == "Somewhat well"
	replace post_t_men_lib = 3 if post_ap_trait_l_8 == "Not too well"
	replace post_t_men_lib = 4 if post_ap_trait_l_8 == "Not at all well"
	label var post_t_men_lib "Traits: Mean (Liberal)"
	label val post_t_men_lib traits_pos
	fre post_t_men_lib 

sum post_t_pat_cons post_t_int_cons post_t_hon_cons post_t_opm_cons post_t_gen_cons post_t_hyp_cons post_t_slf_cons post_t_men_cons post_t_pat_lib post_t_int_lib post_t_hon_lib post_t_opm_lib post_t_gen_lib post_t_hyp_lib post_t_slf_lib post_t_men_lib
local vars post_t_pat_cons post_t_int_cons post_t_hon_cons post_t_opm_cons post_t_gen_cons post_t_hyp_cons post_t_slf_cons post_t_men_cons post_t_pat_lib post_t_int_lib post_t_hon_lib post_t_opm_lib post_t_gen_lib post_t_hyp_lib post_t_slf_lib post_t_men_lib
foreach x of local vars {
clonevar `x'_bin = `x'
replace `x'_bin = (`x'_bin)/4
}


sum post_t_pat_cons_bin post_t_int_cons_bin post_t_hon_cons_bin post_t_opm_cons_bin post_t_gen_cons_bin post_t_hyp_cons_bin post_t_slf_cons_bin post_t_men_cons_bin post_t_pat_lib_bin post_t_int_lib_bin post_t_hon_lib_bin post_t_opm_lib_bin post_t_gen_lib_bin post_t_hyp_lib_bin post_t_slf_lib_bin post_t_men_lib_bin

*Creating measures of affective polarization
	*FTs
		*Using in and out measures
			*AP pre ft
			gen ap_ft_pre = .
			replace ap_ft_pre = pre_ft_cons - pre_ft_lib if conservativism >4
			replace ap_ft_pre = pre_ft_lib - pre_ft_cons if conservativism <4
			replace ap_ft_pre = round(ap_ft_pre, .01)
			label var ap_ft_pre "AP:FT (Pre)"
			sum ap_ft_pre 
			bro pre_ft_cons pre_ft_lib ap_ft_pre
			
			*Ap post ft
			gen ap_ft_post = .
			replace ap_ft_post = post_ft_cons - post_ft_lib if conservativism >4
			replace ap_ft_post = post_ft_lib - post_ft_cons if conservativism <4
			replace ap_ft_post = round(ap_ft_post, .01)
			label var ap_ft_post "AP:FT (Post)"
			sum ap_ft_post 
			
			*Diff between AP pre and post
			gen ap_ft_change = .
			replace ap_ft_change = (ap_ft_post - ap_ft_pre)/2
			label var ap_ft_change "AP:FT ($\Delta$)"
			replace ap_ft_change = round(ap_ft_change, .01)
			sum ap_ft_change 
			
		*Using just out measures
			*AP out party pre
			gen ap_ft_op_pre = .
			replace ap_ft_op_pre = pre_ft_cons if conservativism <4 
			replace ap_ft_op_pre = pre_ft_lib if conservativism >4
			replace ap_ft_op_pre = round(ap_ft_op_pre, .01)
			label var ap_ft_op_pre "AP:FT, Out-Ideology (Pre)"	
			sum ap_ft_op_pre 

			*AP out party post
			gen ap_ft_op_post = .
			replace ap_ft_op_post = post_ft_cons if conservativism <4 
			replace ap_ft_op_post = post_ft_lib if conservativism >4
			replace ap_ft_op_post = round(ap_ft_op_post, .01)
			label var ap_ft_op_post "AP:FT, Out-Ideology (Post)"
			sum ap_ft_op_post 	
			
			*Diff between AP out party pre and post
			gen ap_ft_op_change = .
			replace ap_ft_op_change = ap_ft_op_post - ap_ft_op_pre
			replace ap_ft_op_change = round(ap_ft_op_change, .01)
			label var ap_ft_op_change "AP:FT Out-Ideology ($\Delta$)"
			sum ap_ft_op_change 
		
		*Using just in measures
			*AP in party pre
			gen ap_ft_ip_pre = .
			replace ap_ft_ip_pre = pre_ft_cons if conservativism >4 
			replace ap_ft_ip_pre = pre_ft_lib if conservativism <4
			replace ap_ft_ip_pre = round(ap_ft_ip_pre, .01)
			label var ap_ft_ip_pre "AP:FT, In-Ideology (Pre)"	
			sum ap_ft_ip_pre 

			*AP in party post
			gen ap_ft_ip_post = .
			replace ap_ft_ip_post = post_ft_cons if conservativism >4 
			replace ap_ft_ip_post = post_ft_lib if conservativism <4
			replace ap_ft_ip_post = round(ap_ft_ip_post, .01)
			label var ap_ft_ip_post "AP:FT, In-Ideology (Post)"
			sum ap_ft_ip_post 	
			
			*Diff between AP in party pre and post
			gen ap_ft_ip_change = .
			replace ap_ft_ip_change = ap_ft_ip_post - ap_ft_ip_pre
			replace ap_ft_ip_change = round(ap_ft_ip_change, .01)
			label var ap_ft_ip_change "AP:FT In-Ideology ($\Delta$)"
			sum ap_ft_ip_change 
			
		/*
		*Rescale 0-1
			*AP change
			sum ap_ft_change
			gen ap_ft_change_01 = (ap_ft_change + abs(r(min)))/(r(max)+ abs(r(min)))
			label var ap_ft_change_01 "AP:FT ($\Delta$)"
			sum ap_ft_change_01 
			bro ap_ft_change_01 

			*AP IP change
			sum ap_ft_ip_change
			gen ap_ft_ip_change_01 = (ap_ft_ip_change + abs(r(min)))/(r(max)+ abs(r(min)))
			label var ap_ft_ip_change_01 "AP:FT In-Ideology (`$\Delta$')"
			sum ap_ft_ip_change_01 
		
			*AP OP change
			sum ap_ft_op_change
			gen ap_ft_op_change_01 = (ap_ft_op_change + abs(r(min)))/(r(max)+ abs(r(min)))
			label var ap_ft_op_change_01 "AP:FT Out-Ideology (`$\Delta$')"
			sum ap_ft_op_change_01 
		*/
	
	*Traits
		*Pre
			*Conservative pre
			gen traits_pre_cons = .
			replace traits_pre_cons = ((pre_t_pat_cons + pre_t_int_cons + pre_t_hon_cons + pre_t_opm_cons + pre_t_gen_cons - (pre_t_hyp_cons + pre_t_slf_cons + pre_t_men_cons))+15)/35
			fre traits_pre_cons
			fre traits_pre_cons if conservativism >4
			fre traits_pre_cons if conservativism <4

			*Liberal pre
			gen traits_pre_lib = .
			replace traits_pre_lib = ((pre_t_pat_lib + pre_t_int_lib + pre_t_hon_lib + pre_t_opm_lib + pre_t_gen_lib - (pre_t_hyp_lib + pre_t_slf_lib + pre_t_men_lib))+15)/35
			fre traits_pre_lib
			fre traits_pre_lib if conservativism >4
			fre traits_pre_lib if conservativism <4
			
			*Diff pre
			gen ap_traits_pre = .
			replace ap_traits_pre = traits_pre_lib - traits_pre_cons if conservativism <4
			replace ap_traits_pre = traits_pre_cons - traits_pre_lib if conservativism >4
			sum ap_traits_pre
			label var ap_traits_pre "AP: Traits (Pre)"
		
		*Post
			*Conservative post
			gen traits_post_cons = .
			replace traits_post_cons = ((post_t_pat_cons + post_t_int_cons + post_t_hon_cons + post_t_opm_cons + post_t_gen_cons - (post_t_hyp_cons + post_t_slf_cons + post_t_men_cons))+15)/35
			fre traits_post_cons
			fre traits_post_cons if conservativism >4
			fre traits_post_cons if conservativism <4

			*Liberal post
			gen traits_post_lib = .
			replace traits_post_lib = ((post_t_pat_lib + post_t_int_lib + post_t_hon_lib + post_t_opm_lib + post_t_gen_lib - (post_t_hyp_lib + post_t_slf_lib + post_t_men_lib))+15)/35
			fre traits_post_lib
			fre traits_post_lib if conservativism >4
			fre traits_post_lib if conservativism <4
			
			*Diff post
			gen ap_traits_post = .
			replace ap_traits_post = traits_post_lib - traits_post_cons if conservativism <4
			replace ap_traits_post = traits_post_cons - traits_post_lib if conservativism >4
			sum ap_traits_post
			label var ap_traits_post "AP: Traits (Post)"
			
		*Difference pre-post
			*In ideology
			bro traits_post_cons
			gen ap_traits_ip_change = .
			replace ap_traits_ip_change = traits_post_cons - traits_pre_cons if conservativism >4
			replace ap_traits_ip_change = traits_post_lib - traits_pre_lib if conservativism <4
			sum ap_traits_ip_change
			label var ap_traits_ip_change "AP: Traits, In-Ideology ($\Delta$)"
			
			*Out ideology
			gen ap_traits_op_change = .
			replace ap_traits_op_change = traits_post_cons - traits_pre_cons if conservativism <4
			replace ap_traits_op_change = traits_post_lib - traits_pre_lib if conservativism >4
			sum ap_traits_op_change
			label var ap_traits_op_change "AP: Traits, Out-Ideology ($\Delta$)"
			
			*Both 
			gen ap_traits_change = .
			replace ap_traits_change = (ap_traits_post - ap_traits_pre)/2
			sum ap_traits_change 
			label var ap_traits_change "AP: Traits ($\Delta$)"
			
		/*
		*Rescale 0-1
			sum ap_traits_change
			gen ap_traits_change_01 = (ap_traits_change + abs(r(min)))/(r(max)+ abs(r(min)))
			label var ap_traits_change_01 "AP: Traits ($\Delta$)"
			sum ap_traits_change_01 

			*AP IP change
			sum ap_traits_ip_change
			gen ap_traits_ip_change_01 = (ap_traits_ip_change + abs(r(min)))/(r(max)+ abs(r(min)))
			label var ap_traits_ip_change_01 "AP: Traits, In-Ideology ($\Delta$)"
			sum ap_traits_ip_change_01 
		
			*AP OP change
			sum ap_traits_op_change
			gen ap_traits_op_change_01 = (ap_traits_op_change + abs(r(min)))/(r(max)+ abs(r(min)))
			label var ap_traits_op_change_01 "AP: Traits, Out-Ideology (Diff)"
			sum ap_traits_op_change_01 
		*/
		
		*Individual measures
			*Pre
				gen ap_pre_t_pat = .
				replace ap_pre_t_pat = pre_t_pat_cons - pre_t_pat_lib if conservativism >4
				replace ap_pre_t_pat = pre_t_pat_lib - pre_t_pat_cons if conservativism <4
				label var ap_pre_t_pat "AP: Traits, Patriotic (Pre)"
				fre ap_pre_t_pat
				
				gen ap_pre_t_int = .
				replace ap_pre_t_int = pre_t_int_cons - pre_t_int_lib if conservativism >4
				replace ap_pre_t_int = pre_t_int_lib - pre_t_int_cons if conservativism <4
				label var ap_pre_t_int "AP: Traits, Intelligent (Pre)"
				fre ap_pre_t_int	
				
				gen ap_pre_t_hon = .
				replace ap_pre_t_hon = pre_t_hon_cons - pre_t_hon_lib if conservativism >4
				replace ap_pre_t_hon = pre_t_hon_lib - pre_t_hon_cons if conservativism <4
				label var ap_pre_t_hon "AP: Traits, Honest (Pre)"
				fre ap_pre_t_hon			
				
				gen ap_pre_t_opm = .
				replace ap_pre_t_opm = pre_t_opm_cons - pre_t_opm_lib if conservativism >4
				replace ap_pre_t_opm = pre_t_opm_lib - pre_t_opm_cons if conservativism <4
				label var ap_pre_t_opm "AP: Traits, Optimistic (Pre)"
				fre ap_pre_t_opm			
				
				gen ap_pre_t_gen = .
				replace ap_pre_t_gen = pre_t_gen_cons - pre_t_gen_lib if conservativism >4
				replace ap_pre_t_gen = pre_t_gen_lib - pre_t_gen_cons if conservativism <4
				label var ap_pre_t_gen "AP: Traits, Generous (Pre)"
				fre ap_pre_t_gen		
				
				gen ap_pre_t_hyp = .
				replace ap_pre_t_hyp = pre_t_hyp_cons - pre_t_hyp_lib if conservativism >4
				replace ap_pre_t_hyp = pre_t_hyp_lib - pre_t_hyp_cons if conservativism <4
				label var ap_pre_t_hyp "AP: Traits, Hypocritical (Pre)"
				fre ap_pre_t_hyp		
						
				gen ap_pre_t_slf = .
				replace ap_pre_t_slf = pre_t_slf_cons - pre_t_slf_lib if conservativism >4
				replace ap_pre_t_slf = pre_t_slf_lib - pre_t_slf_cons if conservativism <4
				label var ap_pre_t_slf "AP: Traits, Selfish (Pre)"
				fre ap_pre_t_slf		
								
				gen ap_pre_t_men = .
				replace ap_pre_t_men = pre_t_men_cons - pre_t_men_lib if conservativism >4
				replace ap_pre_t_men = pre_t_men_lib - pre_t_men_cons if conservativism <4
				label var ap_pre_t_men "AP: Traits, Mean (Pre)"
				fre ap_pre_t_men		
			
			*Post
				gen ap_post_t_pat = .
				replace ap_post_t_pat = post_t_pat_cons - post_t_pat_lib if conservativism >4
				replace ap_post_t_pat = post_t_pat_lib - post_t_pat_cons if conservativism <4
				label var ap_post_t_pat "AP: Traits, Patriotic (Post)"
				fre ap_post_t_pat
				
				gen ap_post_t_int = .
				replace ap_post_t_int = post_t_int_cons - post_t_int_lib if conservativism >4
				replace ap_post_t_int = post_t_int_lib - post_t_int_cons if conservativism <4
				label var ap_post_t_int "AP: Traits, Intelligent (Post)"
				fre ap_post_t_int	
				
				gen ap_post_t_hon = .
				replace ap_post_t_hon = post_t_hon_cons - post_t_hon_lib if conservativism >4
				replace ap_post_t_hon = post_t_hon_lib - post_t_hon_cons if conservativism <4
				label var ap_post_t_hon "AP: Traits, Honest (Post)"
				fre ap_post_t_hon			
				
				gen ap_post_t_opm = .
				replace ap_post_t_opm = post_t_opm_cons - post_t_opm_lib if conservativism >4
				replace ap_post_t_opm = post_t_opm_lib - post_t_opm_cons if conservativism <4
				label var ap_post_t_opm "AP: Traits, Optimistic (Post)"
				fre ap_post_t_opm			
				
				gen ap_post_t_gen = .
				replace ap_post_t_gen = post_t_gen_cons - post_t_gen_lib if conservativism >4
				replace ap_post_t_gen = post_t_gen_lib - post_t_gen_cons if conservativism <4
				label var ap_post_t_gen "AP: Traits, Generous (Post)"
				fre ap_post_t_gen		
				
				gen ap_post_t_hyp = .
				replace ap_post_t_hyp = post_t_hyp_cons - post_t_hyp_lib if conservativism >4
				replace ap_post_t_hyp = post_t_hyp_lib - post_t_hyp_cons if conservativism <4
				label var ap_post_t_hyp "AP: Traits, Hypocritical (Post)"
				fre ap_post_t_hyp		
						
				gen ap_post_t_slf = .
				replace ap_post_t_slf = post_t_slf_cons - post_t_slf_lib if conservativism >4
				replace ap_post_t_slf = post_t_slf_lib - post_t_slf_cons if conservativism <4
				label var ap_post_t_slf "AP: Traits, Selfish (Post)"
				fre ap_post_t_slf		
								
				gen ap_post_t_men = .
				replace ap_post_t_men = post_t_men_cons - post_t_men_lib if conservativism >4
				replace ap_post_t_men = post_t_men_lib - post_t_men_cons if conservativism <4
				label var ap_post_t_men "AP: Traits, Mean (Post)"
				fre ap_post_t_men	
	
		*Difference
			gen ap_t_pat = .
			replace ap_t_pat = ap_post_t_pat - ap_pre_t_pat
			label var ap_t_pat "AP: Traits, Patriotic"
			fre ap_t_pat 
	
			gen ap_t_int = .
			replace ap_t_int = ap_post_t_int - ap_pre_t_int
			label var ap_t_int "AP: Traits, Intelligent"
			fre ap_t_int 
		
			gen ap_t_hon = .
			replace ap_t_hon = ap_post_t_hon - ap_pre_t_hon
			label var ap_t_hon "AP: Traits, Honest"
			fre ap_t_hon 	
	
			gen ap_t_opm = .
			replace ap_t_opm = ap_post_t_opm - ap_pre_t_opm
			label var ap_t_opm "AP: Traits, Optimistic"
			fre ap_t_opm 		
	
			gen ap_t_gen = .
			replace ap_t_gen = ap_post_t_gen - ap_pre_t_gen
			label var ap_t_gen "AP: Traits, Generous"
			fre ap_t_gen 		
		
			gen ap_t_hyp = .
			replace ap_t_hyp = ap_post_t_hyp - ap_pre_t_hyp
			label var ap_t_hyp "AP: Traits, Hypocritical"
			fre ap_t_hyp 		
			
			gen ap_t_slf = .
			replace ap_t_slf = ap_post_t_slf - ap_pre_t_slf
			label var ap_t_slf "AP: Traits, Selfish"
			fre ap_t_slf 		
				
			gen ap_t_men = .
			replace ap_t_men = ap_post_t_men - ap_pre_t_men
			label var ap_t_men "AP: Traits, Mean"
			fre ap_t_men 		

		*Rescale
		sum ap_t_pat ap_t_int ap_t_hon ap_t_opm ap_t_gen ap_t_hyp ap_t_slf ap_t_men
		local vars ap_t_pat ap_t_int ap_t_hon ap_t_opm ap_t_gen ap_t_hyp ap_t_slf ap_t_men
		foreach var of local vars {
		sum `var'
		gen `var'_01 = (`var' - r(min)) / (r(max) - r(min))
		}
		sum ap_t_pat_01 ap_t_int_01 ap_t_hon_01 ap_t_opm_01 ap_t_gen_01 ap_t_hyp_01 ap_t_slf_01 ap_t_men_01
		
			*Pre
				label var ap_t_pat_01 "AP: Traits, Patriotic"
				fre ap_t_pat_01
				
				label var ap_t_int_01 "AP: Traits, Intelligent"
				fre ap_t_int_01	
				
				label var ap_t_hon_01 "AP: Traits, Honest"
				fre ap_t_hon_01			
				
				label var ap_t_opm_01 "AP: Traits, Optimistic"
				fre ap_t_opm_01			
				
				label var ap_t_gen_01 "AP: Traits, Generous"
				fre ap_t_gen_01		
				
				label var ap_t_hyp_01 "AP: Traits, Hypocritical"
				fre ap_t_hyp_01		
						
				label var ap_t_slf_01 "AP: Traits, Selfish"
				fre ap_t_slf_01		
								
				label var ap_t_men_01 "AP: Traits, Mean"
				fre ap_t_men_01		
	
*Drop those who did not answer key questions or are moderates	
drop if ap_ft_change == . | ap_traits_change == .
drop if liberal == 0 &conserv == 0

save "G:\My Drive\Backup 08202022\Working Papers\RCV and AP\Data and Methods\RCV AP Data Cleaned.dta", replace